package com.zk.shop.servlet.Msg;

import com.zk.shop.entity.Msg;
import com.zk.shop.service.Impl.MsgServiceImpl;
import com.zk.shop.service.MsgService;
import com.zk.shop.util.JSONServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
@WebServlet("/GetMsgByGoodsId")
public class GetMsgByGoodsId extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       int goodsid = Integer.parseInt(request.getParameter("goodsId"));
       // int goodsid = 2;
        MsgService msgService = new MsgServiceImpl();
       List<Msg> msgList=msgService.getMsgByGoodsId(goodsid);
        JSONServlet.getJson(request,response,msgList);
     /*  if (msgList.size()>0){
           response.sendRedirect("SelectReplybyMsgId");
           session.setAttribute("msgList",msgList);
         System.out.println("查询所有留言成功"+msgList.size());


       }
else {
           response.sendRedirect(".jsp");

}*/
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
